package com.aigou.admin.aigouspringboot.service.impl;

import com.aigou.admin.aigouspringboot.common.Constants;
import com.aigou.admin.aigouspringboot.entity.CarouselFigure;
import com.aigou.admin.aigouspringboot.mapper.CarouselFigureMapper;
import com.aigou.admin.aigouspringboot.service.CarouselFigureService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CarouselFigureServiceImpl implements CarouselFigureService {
    @Resource
    private CarouselFigureMapper carouselFigureMapper;


    @Override
    public List<CarouselFigure> selectAll() {
        return carouselFigureMapper.selectAll();
    }

    @Override
    public PageInfo<CarouselFigure> selectCarouselFiguresByPage(Integer current) {
        PageHelper.startPage(current, Constants.PAGE_SIZE);
        List<CarouselFigure> carouselFigures=carouselFigureMapper.selectAll();
        return new PageInfo<>(carouselFigures);
    }

    @Override
    public CarouselFigure selectById(String id) {
        return carouselFigureMapper.selectByPrimaryKey(id);
    }

    @Override
    public int save(CarouselFigure carouselFigure) {
        return carouselFigureMapper.insert(carouselFigure);
    }

    @Override
    public int edit(CarouselFigure carouselFigure) {
        return carouselFigureMapper.updateByPrimaryKeySelective(carouselFigure);
    }

    @Override
    public int deleteById(String id) {
        return carouselFigureMapper.deleteByPrimaryKey(id);
    }
}
